<template>
	<view>
		<u-loading-icon :show="loadingStatus" text="正在加载..." textSize="14" size="17"></u-loading-icon>
		<view v-show="loadingStatus==false">
			<view v-if="cartypeList.length">
				<motorcycle v-for="item in cartypeList" :key="item.id" :img-url="item.carImgLink"
					:title="item.name" :subtitle="item.code"
					@click="$navigateTo('/pagesMy/views/webview?title='+title+'&id='+item.id)"></motorcycle>
			</view>
			<cust-empty desc="暂无数据" v-else>
			</cust-empty>
		</view>
	</view>
</template>

<script>
	import Motorcycle from "../components/motorcycle";
	import {
		getCarTypePageByUserId
	} from "@/api/api/car.js"
	import custEmpty from "@/components/cust-empty/index.vue";
	export default {
		components: {
			Motorcycle,
			custEmpty
		},
		data() {
			return {
				loadingStatus:true,
				title: '',
				cartypeList: []
			}
		},
		onLoad(params) {
			this.loadingStatus = true;
			getCarTypePageByUserId().then(([err, data]) => {
				if (err) return;
				let list = data.records;
				let newList = [];
				list.forEach((item)=>{
					newList.push({
						id:item.id,
						carImgLink:item.carImgLink,
						name:item.name,
						code:item.code,
					})
				})
				this.cartypeList = newList;
				this.loadingStatus = false;
			})
			this.title = params.title;
			uni.setNavigationBarTitle({
				title: params.title
			})

		}
	}
</script>

<style lang="scss" scoped>
	::v-deep .u-loading-icon{
		margin-top: 60rpx !important;
	}
</style>
